<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>AngelScript: Strings</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">AngelScript
   
   </div>
   
  </td>
  
  
  
   
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('doc_datatypes_strings.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">Strings </div>  </div>
</div>
<div class="contents">
<div class="textblock"><p><b>Observe:</b> Strings are only available in the scripts if the application registers the support for them. The syntax for using strings may differ for the application you're working with so consult the application's manual for more details.</p>
<p>Strings hold an array of bytes or 16bit words depending on the application settings. Normally they are used to store text but can really store any kind of binary data.</p>
<p>There are two types of string constants supported in the AngelScript language, the normal quoted string, and the documentation strings, called heredoc strings.</p>
<p>The normal strings are written between double quotation marks (<code>"</code>) or single quotation marks (<code>'</code>). Inside the constant strings some escape sequences can be used to write exact byte values that might not be possible to write in your normal editor.</p>
<table  cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="100" valign="top"><b>sequence</b> </td><td valign="top" width="100"><b>value</b> </td><td valign="top"><p class="starttd"><b>description</b></p>
<p class="endtd"></p>
</td></tr>
<tr>
<td width="80" valign="top"><code>\0</code>&#160;  </td><td valign="top" width="50">0 </td><td valign="top">null character </td></tr>
<tr>
<td width="80" valign="top"><code>\\</code>&#160;  </td><td valign="top" width="50">92 </td><td valign="top">back-slash </td></tr>
<tr>
<td width="80" valign="top"><code>\'</code>&#160;  </td><td valign="top" width="50">39 </td><td valign="top">single quotation mark (apostrophe) </td></tr>
<tr>
<td width="80" valign="top"><code>\"</code>&#160;  </td><td valign="top" width="50">34 </td><td valign="top">double quotation mark </td></tr>
<tr>
<td width="80" valign="top"><code>\n</code>&#160;  </td><td valign="top" width="50">10 </td><td valign="top">new line feed </td></tr>
<tr>
<td width="80" valign="top"><code>\r</code>&#160;  </td><td valign="top" width="50">13 </td><td valign="top">carriage return </td></tr>
<tr>
<td width="80" valign="top"><code>\t</code>&#160;  </td><td valign="top" width="50">9 </td><td valign="top">tab character </td></tr>
<tr>
<td width="80" valign="top"><code>\xFFFF</code>&#160; </td><td valign="top" width="50">0xFFFF </td><td valign="top">FFFF should be exchanged for a 1 to 4 digit hexadecimal number representing the value wanted. If the application uses 8bit strings then only values up to 255 is accepted. </td></tr>
<tr>
<td width="80" valign="top"><code>\uFFFF</code>&#160; </td><td valign="top" width="50">0xFFFF </td><td valign="top">FFFF should be exchanged for the hexadecimal number representing the unicode code point </td></tr>
<tr>
<td width="80" valign="top"><code>\UFFFFFFFF</code>&#160; </td><td valign="top" width="50">0xFFFFFFFF </td><td valign="top">FFFFFFFF should be exchanged for the hexadecimal number representing the unicode code point </td></tr>
</table>
<pre>
  string str1 = "This is a string with \"escape sequences".";
  string str2 = 'If single quotes are used then double quotes can be included without "escape sequences".';
</pre><p>The heredoc strings are designed for inclusion of large portions of text without processing of escape sequences. A heredoc string is surrounded by triple double-quotation marks (<code>"""</code>), and can span multiple lines of code. If the characters following the start of the string until the first linebreak only contains white space, it is automatically removed by the compiler. Likewise if the characters following the last line break until the end of the string only contains white space this is also remove, including the linebreak.</p>
<pre>
  string str = """
  This is some text without "escape sequences". This is some text.
  This is some text. This is some text. This is some text. This is
  some text. This is some text. This is some text. This is some
  text. This is some text. This is some text. This is some text.
  This is some text.
  """;
</pre><p>If more than one string constants are written in sequence with only whitespace or comments between them the compiler will concatenate them into one constant.</p>
<pre>
  string str = "First line.\n"
               "Second line.\n"
               "Third line.\n";
</pre><p>The escape sequences \u and \U will add the specified unicode code point as a UTF-8 or UTF-16 encoded sequence depending on the application settings. Only valid unicode 5.1 code points are accepted, i.e. code points between U+D800 and U+DFFF (reserved for surrogate pairs) or above U+10FFFF are not accepted.</p>
<p>The standard string implementation also comes with the following methods:</p>
<pre>
  // Returns the length of the string
  uint length() const;</pre><pre>  // Assignment and concatenation
  string &amp;opAssign(const string &amp;in other);
  string &amp;opAddAssign(const string &amp;in other);
  string  opAdd(const string &amp;in right) const;</pre><pre>  // Access individual characters
  uint8       &amp;opIndex(uint);
  const uint8 &amp;opIndex(uint) const;</pre><pre>  // Comparison operators
  bool opEquals(const string &amp;in right) const;
  int  opCmp(const string &amp;in right) const;</pre><pre>  // Substring
  string substr(uint start = 0, int count = -1) const;
  array&lt;string&gt;@ split(const string &amp;in delimiter) const;</pre><pre>  // Search
  int findFirst(const string &amp;in str, uint start = 0) const;
  int findLast(const string &amp;in str, int start = -1) const;</pre><pre>  // Automatic conversion from primitive types to string type
  string &amp;opAssign(double val);
  string &amp;opAddAssign(double val);
  string  opAdd(double val) const;
  string  opAdd_r(double val) const;</pre><pre>  string &amp;opAssign(int val);
  string &amp;opAddAssign(int val);
  string  opAdd(int val) const;
  string  opAdd_r(int val) const;</pre><pre>  string &amp;opAssign(uint val);
  string &amp;opAddAssign(uint val);
  string  opAdd(uint val) const;
  string  opAdd_r(uint val) const;</pre><pre>  string &amp;opAssign(bool val);
  string &amp;opAddAssign(bool val);
  string  opAdd(bool val) const;
  string  opAdd_r(bool val) const;
</pre><p>There is also a standard global function joining an array of strings into a single string with delimeter.</p>
<pre>
  string join(const array&lt;string&gt; &amp;in arr, const string &amp;in delimiter);
</pre> </div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>

    <li class="footer">Generated on Sun Jan 29 2012 15:41:04 for AngelScript by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
